<?php
/**
 * @title 96. 不同的二叉搜索树 - 卡塔兰数
 * @author start2004
 */

class Solution {

    /**
     * @param Integer $n
     * @return Integer
     */
    function numTrees($n) {
        /**
         * @since 2020-08-13 结果集
         */
        $result = 1;

        /**
         * @since 2020-08-13 卡塔兰数
         */
        for ($i=1; $i<=$n; $i++){
            $result = $result*(($i<<2)-2)/($i+1);
        }

        /**
         * @return
         */
        return $result;
    }
}




/**
 * @url http://127.0.0.1/leetcode/202007/2020.07.15_7.php
 */
$datas = [
    3,
];

include_once dirname(__DIR__) . DIRECTORY_SEPARATOR ."xhprof.php";
$xhprof = new Xhprof();
foreach ($datas as $data){
    var_dump($data);

    $obj = new Solution();
    $result = $obj->numTrees($data);
    var_dump($result);
    echo str_repeat("<br>", 3);
}
$xhprof->end();
